package com.share.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author caifan
 * @since 2023/8/19
 */
@Slf4j
@Component
public class ConsumerMessage {

    @RabbitListener(queues = "share.directQueue")
    @RabbitHandler
    public void consumer01(Channel channel, Message message) throws IOException {
        log.info("nack 消息:{}", new String(message.getBody()));
        channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);

    }
}
